package io.lvdaxian.mybatis14.builder;

import io.lvdaxian.mybatis14.mapping.ResultMap;
import io.lvdaxian.mybatis14.mapping.ResultMapping;

import java.util.List;

/**
 * 表示 ResultMap 的解析器
 *
 * @author lihh
 */
public class ResultMapResolver {
  
  private final MapperBuilderAssistant assistant;
  private String id;
  private Class<?> type;
  private List<ResultMapping> resultMappings;
  
  public ResultMapResolver(MapperBuilderAssistant assistant, String id, Class<?> type, List<ResultMapping> resultMappings) {
    // assistant MapperBuilder 构建助手
    this.assistant = assistant;
    this.id = id;
    this.type = type;
    this.resultMappings = resultMappings;
  }
  
  public ResultMap resolve() {
    return assistant.addResultMap(this.id, this.type, this.resultMappings);
  }
}
